<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="org.json.JSONObject"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="db.UserDAO"%>
<%@page import="db.TitleDAO" %>
<%@page import="db.User"%>
<%@page import="db.GroupDAO"%>


<%
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setDateHeader("Expires", 0);
	response.setContentType("application/x-javascript");
	out.clear();
	//System.out.println("===========");
	String callback = request.getParameter("callback");
	String jsonString = request.getParameter("jsonString");
	JSONObject requestJSONobject = new JSONObject(jsonString);
	JSONObject responseJSONObject = new JSONObject();
	
	String acc = requestJSONobject.optString("acc");
	
	WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
	UserDAO userDao = (UserDAO)ctx.getBean("UserDAO");
	List list = userDao.findByAccount(acc);
	//System.out.println(list.size()+"====username==="+acc);
	if(list != null && list.size() > 0){
		responseJSONObject.put("success", false);
		responseJSONObject.put("message", "管理员登录名已经存在");
		String result = callback + "('" + responseJSONObject.toString() + "');";
		out.write(result);
		//return;
	}else{
		responseJSONObject.put("success", true);
		responseJSONObject.put("message", "管理员登录名可以使用");
		String result = callback + "('" + responseJSONObject.toString() + "');";
		out.write(result);
		//return;
	}
	
%>
